package com.sign.common.util.uuid;

import java.security.SecureRandom;
import java.util.UUID;

public class UuidCreater
{
  private static SecureRandom random = new SecureRandom();

  public static String uuid()
  {
    return UUID.randomUUID().toString().replaceAll("-", "");
  }

  public static long randomLong()
  {
    return Math.abs(random.nextLong());
  }

  public static String randomBase62(int length)
  {
    byte[] randomBytes = new byte[length];
    random.nextBytes(randomBytes);
    return Encodes.encodeBase62(randomBytes);
  }

  public static long longUUID() {
    return UUID.randomUUID().getMostSignificantBits();
  }

  public static long absLongUUID() {
    long r;
    do
      r = longUUID();
    while (r <= 2162214659975806976L);
    return r;
  }
}